<?php get_header(); ?>
<?php
    $events = db_event_get($_REQUEST['id']);
    $event = $events[0];
?>

		<div id="main-top">
			<div class="main-top-left">
			    <h4>Event Summary</h4>
			</div>
			<?php if (is_file(STYLESHEETPATH . '/subscribe.php' )) include(STYLESHEETPATH . '/subscribe.php' ); else include(TEMPLATEPATH . '/subscribe.php' ); ?>
		</div>
		<div id="main" class="clear">
			<div id="content">
			    <script type="text/javascript">
				var $j = jQuery.noConflict();
				$j(function() {
				    
				});
			    </script>
			    <h2 class="event-title"><?php echo $event["name"] . " in " . $event["location"]; ?></h2>
			    <br />
			    
				
			    <div class="summary" style="float: left">
				<p><strong>Location:</strong> <?= $event["location"] ?></p>
				<p><strong>Active Support:</strong> <?= ($event["active"]!="0") ? "Yes" : "No" ?></p>
				<p style="width: 220px;">
				    <strong>Description:</strong>
				    <br /><?= $event["description"] ?>
				</p>
			    </div>
			    <div style="float: right">
				<?php
				     require plugins_url() . "/disaster_plugin/map.php";
				     $geocode = explode(" ", $event['geocode']);
				     map_show_location($geocode[1], $geocode[0]);
				?>
			    </div>
			    <br /><br />
			    <div style="clear: both" class="summary">
				<p><strong>Shipments:</strong></p>
				<?php
				    $shipments = db_shipments_by_event($event['event_id']);
				    foreach($shipments as $shipment)
				    {
				?>
				<p><?php echo $shipment['date_sent'];?></p>
				<table style="margin-left: 12px;">
				<?php
					$supplies = db_supplies_by_shipment($shipment['shipment_id']);
					$x = 0;
					foreach($supplies as $supply)
					{
					    $totals = db_supplies_total($supply['type'], $event['event_id']);
					    $total = $totals[0];
					    $sum = $total['SUM'];
					    if (!$sum)
						$sum = "0";
					    $x++;
					    $pb = "progressbar-" . $shipment['shipment_id'] . "-" . $x;
					    $needed = $supply['amount_needed'];
					    $percent = floatval($sum) / floatval($needed);
					    $value = intval($percent * 100);
				?>
				    <tr>
				
					<td style="text-transform: capitalize; width: 160px">
					    <?= $supply['type'] . ":"?>
					</td>
					<td style="width: 140px; text-align: right; padding-right: 20px;">
					    <?= $sum . " / " . $needed . " " . $supply['unit'] ?>
					</td>
					<td>
					    <div id="<?= $pb ?>" style="width: 300px; height: 20px; float: right"></div>
					</td>
					<script type="text/javascript">
					    $j(function () {
						$j("#<?= $pb ?>").progressbar({ value: <?= $value ?> });
					    });
					</script>
				    </tr>
				
				<?php
					}
				?>
				</table>
				<?php
				    }
				?>
			    </div>
				
			   
			</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>